﻿@model ChangePasswordEditModel
@{
    Layout = "_UserSpaceSettings";
    ViewData["UserSettingsMenu"] = UserSettingsMenu.ChangePassword;
    Uri returnUri = HttpContext.Current.Request.UrlReferrer;
}
@section Aside
{
    @Html.Partial("_UserSettingsMenus")
}
<div class="tn-box tn-widget tn-widget-content tn-corner-all tnc-form-info">
    <div class="tn-box-content tn-widget-content tn-corner-all">
        <div class="tnc-reset-wrapper">
		    <div class="tn-main-heading tn-border-gray tn-border-bottom">
				<h2>修改密码</h2>
            </div>
            @using (Html.BeginAjaxForm("ChangePassword", "UserSpaceSettings", FormMethod.Post, new AjaxFormOptions { OnSuccessCallBack = "ChangePasswordOnSuccessCallBack", OnErrorCallBack = "ChangePasswordOnErrorCallBack" }))
            {
                if (ViewData["StatusMessage"] != null)
                {
                @Html.StatusMessage(ViewData["StatusMessage"] as StatusMessageData)
                }
                else
                {
                <div class="tn-cue-highlight tn-corner-all tn-message-box">
                    <span class="tn-helper-left"><span class="tn-icon tn-icon-exclamation"></span></span>
                    <div class="tn-helper-flowfix">
                        <strong>提示：</strong> 修改密码之后，下次登录时需要使用新密码登录
                    </div>
                </div>
                }
                
                <div class="tn-form tn-label-right">
                    <div class="tn-form-row">
                        @Html.FormLabelFor(n => n.UserName)
                        @Html.TextBoxFor(n => n.UserName, InputWidthTypes.Long, new RouteValueDictionary { { "class", "tnc-watermark-color" }, { "readonly", "readonly" } })
                    </div>
                    <div class="tn-form-row">
                        @Html.FormLabelFor(n => n.OldPassword)
                        @Html.TextBoxFor(n => n.OldPassword, InputWidthTypes.Long, new RouteValueDictionary { { "class", "tnc-watermark-color" }, { "type", "password" }, { "autocomplete", "off" } })
                        @Html.ValidationMessageFor(n => n.OldPassword)
                    </div>
                    <div class="tn-form-row">
                        @Html.FormLabelFor(n => n.Password)
                        @Html.TextBoxFor(n => n.Password, InputWidthTypes.Long, new RouteValueDictionary { { "class", "tnc-watermark-color" }, { "type", "password" } })
                        @Html.ValidationMessageFor(n => n.Password)
                    </div>
                    <div class="tn-form-row">
                        @Html.FormLabelFor(n => n.ComparePassword)
                        @Html.TextBoxFor(n => n.ComparePassword, InputWidthTypes.Long, new RouteValueDictionary { { "class", "tnc-watermark-color" }, { "type", "password" } })
                        @Html.ValidationMessageFor(n => n.ComparePassword)
                    </div>
                    <div class="tn-form-row tn-form-row-button">
                        <label class="tn-form-label">
                        </label>
                        @Html.Button("修改密码", ButtonTypes.Submit, HighlightStyles.Primary, ButtonSizes.Large)
                        @if (returnUri != null)
                        {
                            @Html.Button("取消", ButtonTypes.Link, HighlightStyles.Secondary, ButtonSizes.Large, url: returnUri.AbsoluteUri)
                        }
                    </div>
                </div>
            }
        </div>
    </div>
</div>
<script language="javascript" type="text/javascript">
    function ChangePasswordOnSuccessCallBack(data) {
        art.dialog.tips(data.MessageContent, 1.5, data.MessageType);
    }
    function ChangePasswordOnErrorCallBack(data) {
        data = $.parseJSON(data);
        art.dialog.tips(data.MessageContent, 1.5, data.MessageType);
    }
</script>
